#!/usr/bin/env python3
# coding: utf-8

from utils.tcphandler import TCPHandler
from utils.logger import get_logger


logger = get_logger(__name__)


class HeartbeatHandler(TCPHandler):
    """心跳包"""
    response_data = {
        "success": {
            "code": "0",
            "cmd": "1001",
            "data": {
                "msg": "PONG"
            }
        }
    }
    #
    # def __init__(self, *args, **kwargs):
    #     super(HeartbeatHandler, self).__init__(*args, **kwargs)

    async def write(self):
        # logger.info("Heartbeat => {}".format(self.data))
        # if not isinstance(self.data, dict):
        #     return

        logger.info("stream io => {}".format(self.stream))
        self.response(self.stream, self.response_data.get('success'))

